import { http } from "@/utils/http";
import { ListResult } from "./models";
import {CtaInfoType} from "./cta.ts";
import {logRecordType} from "./logRecord.ts";


interface checkRegisterType {
  status: boolean
}
export const checkRegister = (data: object) => {
  return http.request<ListResult<checkRegisterType>>("post", '/api/open/resource/campaign/checkRegister',{
    data
  });
}


interface ExhibitionType{
  name:string
  thumb_material_uuid:string
  file_material_uuid:string
  thumb:string
  view:number
  download:number
}
interface SpeakerType{
  name:string
  desc:string
  thumb_material_uuid: string
  thumb:string
}
interface ScheduleType{
  name:string,
  time:string,
  startTime:string,
  endTime:string,
  speaker:string
}

interface OrganizationType{
  name:string
  type:string
  thumb:string
  thumb_material_uuid:string
}
interface ContactType{
  code:string
  name:string
  value:string
}

export type CampaignType = {
  uuid: string;
  name:string,
  thumb:string,
  thumb_material_uuid:string,
  start_at:string,
  end_at:string,
  address:string,
  introduce:{
    name: string,
    introduce: string
  },
  exhibition:{
    name: string,
    exhibitions:ExhibitionType[]
  },
  speaker:{
    name: string,
    speakers: SpeakerType[]
  },
  schedule:{
    name: string,
    schedules:ScheduleType[]
  },
  organization:{
    name: string,
    organizations: OrganizationType[]
  },
  notice:{
    name:string,
    notice:string
  },
  contact:{
    name: string
    contacts: ContactType[]
  },
  registration:{
    name:string,
    color:string,
    cta_info:CtaInfoType,
    review:boolean
  }
};

/** 用户详情 */
export const campaignInfo = (uuid:string) => {
  return http.request<ListResult<CampaignType>>("get", `/api/open/resource/campaign/${uuid}`);
};


export const logRecord = (data: object) => {
  return http.request<ListResult<logRecordType>>("post", '/api/open/resource/campaign/log',{
    data
  });
}